<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:cgf="http://www.centralgold.com.br/facelets"
    template="/layout/template.xhtml">

<ui:define name="body">

    <h:form id="agendasForm">

        <rich:panel>
            <f:facet name="header">Cadastrar Agenda</f:facet>
            <div id="campos">
	            <s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">Data de inicial:</ui:define>
					<rich:calendar
						value="#{cadastrarAgenda.dataInicial}"
						required="false" enableManualInput="true"
						locale="pt_BR"
						inputSize="12"
						showWeekDaysBar="false" showFooter="false"
						datePattern="dd/MM/yyyy" oninputkeydown="Mascara(this,Data)"
						oninputkeyup="Mascara(this,Data)"
						monthLabelsShort="Jan,Fev,Mar,Abr,Mai,Jun,Jul,Ago,Set,Out,Nov,Dez"
		            	weekDayLabelsShort="Dom,Seg,Ter,Qua,Qui,Sex,Sáb"
		            	weekDayLabels="Domingo,Segunda,Terça,Quarta,Quinta,Sexta,Sábado" 
						showWeeksBar="false" />
				</s:decorate>
				
	            <s:decorate template="/layout/edit.xhtml">
					<ui:define name="label">Data de final:</ui:define>
					<rich:calendar
						value="#{cadastrarAgenda.dataFinal}"
						required="false" enableManualInput="true"
						showWeekDaysBar="false" showFooter="false"
						locale="pt_BR"
						inputSize="12"
						datePattern="dd/MM/yyyy" oninputkeydown="Mascara(this,Data)"
						oninputkeyup="Mascara(this,Data)"
						monthLabels="Janeiro,Fevereiro,Março,Abril,Maio,Junho,Julho,Agosto,Setembro,Outubro,Novembro,Dezembro"
		            	monthLabelsShort="Jan,Fev,Mar,Abr,Mai,Jun,Jul,Ago,Set,Out,Nov,Dez"
		            	weekDayLabelsShort="Dom,Seg,Ter,Qua,Qui,Sex,Sáb"
		            	weekDayLabels="Domingo,Segunda,Terça,Quarta,Quinta,Sexta,Sábado" 
						showWeeksBar="false"/>
				</s:decorate>
            </div>
            <br style="clear:both;" />
            <div align="center">
	            <h:commandButton id="pesq" value="Pesquisar" action="#{cadastrarAgenda.pesquisar()}"/>
	        </div>
			<br />
			
			<rich:dataTable id="tabelaAgendas" 
				value="#{cadastrarAgenda.listaAgendamentos}"
				rows="20"
				onRowMouseOver="this.style.backgroundColor='#6495ED'"
       			onRowMouseOut="this.style.backgroundColor='#FFFFCC'"
				var="_agenda">
				
				<rich:column>
					<f:facet name="header">
						<h:selectBooleanCheckbox value="#{cadastrarAgenda.selecionadoTodos}" >
							<a:support event="onchange" 
								action="#{cadastrarAgenda.selecionaTodos()}"
								reRender="tabelaAgendas"/>
						</h:selectBooleanCheckbox>
					</f:facet>
					<h:selectBooleanCheckbox value="#{_agenda.selecionado}" />				
				</rich:column>
				
				<rich:column>
					<f:facet name="header">Veículo</f:facet>
					<h:outputText value="#{_agenda.automovel.marca}/#{_agenda.automovel.modelo} - #{_agenda.automovel.cor}" />				
				</rich:column>
				
				<rich:column>
					<f:facet name="header">Cliente</f:facet>
					<h:outputText value="#{_agenda.cliente.nome}" rendered="#{_agenda.cliente != null}"/>				
				</rich:column>
				
				<rich:column>
					<f:facet name="header">Data Início</f:facet>
					<h:outputText value="#{_agenda.dataInicio}" >
						<s:convertDateTime pattern="dd/MM/yyyy - HH:mm"/>
					</h:outputText>				
				</rich:column>
				
				<rich:column>
					<f:facet name="header">Data Fim</f:facet>
					<h:outputText value="#{_agenda.dataFim}" >
						<s:convertDateTime pattern="dd/MM/yyyy - HH:mm"/>
					</h:outputText>				
				</rich:column>
				
				<rich:column rendered="#{identity.hasRole('CADASTRAR_AGENDA_GRAVAR')}">
					<f:facet name="header"></f:facet>
					<s:div style="float:left">
						<h:commandButton value="EDITAR" 
							image="/img/btn_editar.png"
							alt="EDITAR"
							title="Pressione aqui para editar o agendamento"
							action="#{cadastrarAgenda.editar(_agenda)}" />
					</s:div>
					<rich:spacer width="10px"/>
					<s:div style="float:left">
						<h:commandButton id="btnRealizarAluguel" 
							action="#{cadastrarAluguel.converterAgendaToAluguel(_agenda)}"
							image="/estatico/img/reprocessar.gif" 
							title="Pressione aqui para transformar o agendamento em aluguel"
							value="REALIZAR_ALUGUEL" />	
					</s:div>
					<s:div style="clear: both" />								
				</rich:column>
			</rich:dataTable>
			<rich:datascroller for="tabelaAgendas" renderIfSinglePage="false"/>
        </rich:panel>

        <div class="actionButtons">
            <h:commandButton id="novo" value="Novo" action="#{cadastrarAgenda.novo()}"
            	rendered="#{identity.hasRole('CADASTRAR_AGENDA_GRAVAR')}"/>
            <h:commandButton id="excluir" value="Excluir" action="#{cadastrarAgenda.excluir()}"
            	rendered="#{identity.hasRole('CADASTRAR_AGENDA_EXCLUIR')}"
            	onclick="javascript:if(!confirm('Tem certeza que deseja excluir?'))return false;"/>
        </div>

    </h:form>

 </ui:define>
</ui:composition>
